package com.cci.kangdao.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

import java.util.List;
import java.util.Map;


/**
 * 技师处理工单类
 * @author zhangzhuang
 *
 */
@MapperScan
public interface TechDealWithWorkOrderDao {
	
	//服务技师接单和拒单后修改相关工单信息
	@Update({"<script>",
	    "update WorkOrder_T set",
	    "<when test='ReceiveTimeEngineer!=null'>",
	    "ReceiveTimeEngineer=#{ReceiveTimeEngineer},",
	    "</when>",
	    "<when test='RefuseTimeEngineer!=null'>",
	    "RefuseTimeEngineer=#{RefuseTimeEngineer},",
	    "</when>",
	    "<when test='RefuseReasonEngineer!=null'>",
	    "RefuseReasonEngineer=#{RefuseReasonEngineer},",
	    "</when>",
	    "<when test='ServiceStationId!=null'>",
	    "ServiceStationId=#{ServiceStationId},",
	    "</when>",
	    "OrderStatus=#{OrderStatus},Updator=#{Updator},UpdateTime=#{UpdateTime} where ID = #{workOrderId} and UpdateTime=#{OldUpdateTime}",
	    "</script>"})		
	public int serviceTechnicianReceiveOrRefuseWorkOrder(Map<String, Object> map);

  /**
   * 技师点击出发
   * @param map
   * @return
   */
  public int updateWorkOrderStatus(Map<String,Object> map);
  
  /**
   * 获取工单基本信息
   * @param map
   * @return
   */
  public List<Map<String,Object>> getCurrentOrderMsg(Map<String,Object> map);
  
  /**
   * 保存工单轨迹点
   * @param map
   * @return
   */
  public int saveOrderTrack(Map<String,Object> map);
  
  /**
   * 根据用户手机号查询用户基本信息
   * @param cusPhone
   * @return
   */
  public List<Map<String,Object>> getCustomerList(String cusPhone);
  
  /**
   * 技师点击到达
   * @param map
   * @return
   */
  public int upWorkOrderStatus(Map<String,Object> map);
  
  /**
   * 根据用户手机号查询用户基本信息
   * @param cusPhone
   * @return
   */
  public List<Map<String,Object>> getWorkOrderTrack(Map<String,Object> map);
  /**
   * 根据工单ID查询工单责任人表
   * @param cusPhone
   * @return
   */
  public List<Map<String,Object>> getWorkOrderPrincipal(Map<String,Object> map);
  
  /**
   * 查询该企业是否在高德已创建
   * @param map
   * @return
   */
  public Map<String,Object> getGolden_Company(Map<String,Object> map);
  /**
   * 查询高德轨迹 数据库是否存在该企业与服务站的关系
   * @param map
   * @return
   */
  public Map<String,Object> getGolden_Company_Service(Map<String,Object> map);
  
  /**
   * 保存上传到高德的  企业与服务站的关系
   * @param map
   * @return
   */
  public int saveCompany_Service(Map<String,Object> map);
  
  /**
   * 查看数据库  服务站与工单轨迹的关系
   * @param map
   * @return
   */
  public Map<String,Object> getTrace_Service(Map<String,Object> map);
  
  /**
   * 保存服务站与工单轨迹的关系
   * @param map
   * @return
   */
  public int saveTrace_Service(Map<String,Object> map);
  
  /**
   * 获取该工单轨迹
   * @param map
   * @return
   */
  public List<Map<String,Object>> getOrderTrace(Map<String,Object> map);


  //保存ccec副技师点击出发到达保存操作记录信息
  int saveWorkOrderTechnicianOperator(Map<String,Object> map);

    List<Integer> getOrderStatusOrderId(@Param("orderId") Long orderId);

}
